﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContractInformation.ascx.cs"
    Inherits="ContractInformation" %>
<br />
<br />
<asp:GridView ID="GridViewContractInformation" runat="server" AutoGenerateColumns="False"
    DataSourceID="SqlDataSourceContract">
    <Columns>
        <asp:BoundField DataField="Название предприятия" HeaderText="Название предприятия"
            SortExpression="Название предприятия" />
        <asp:BoundField DataField="Номер договора" HeaderText="Номер договора" SortExpression="Номер договора" />
        <asp:BoundField DataField="Кредит" HeaderText="Кредит" SortExpression="Кредит" />
        <asp:BoundField DataField="Процент" HeaderText="Процент" SortExpression="Процент" />
        <asp:BoundField DataField="Сумма" HeaderText="Сумма" SortExpression="Сумма" />
        <asp:BoundField DataField="Валюта" HeaderText="Валюта" SortExpression="Валюта" />
        <asp:BoundField DataField="Срок" HeaderText="Срок" SortExpression="Срок" />
        <asp:BoundField DataField="Дата получения" HeaderText="Дата получения" SortExpression="Дата получения" />
        <asp:BoundField DataField="Ф.И.О руководителя" HeaderText="Ф.И.О руководителя" SortExpression="Ф.И.О руководителя" />
        <asp:BoundField DataField="Телефон" HeaderText="Телефон" SortExpression="Телефон" />
        <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
    </Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceContract" runat="server" ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>"
    SelectCommand="SELECT Company.CompanyName AS [Название предприятия], Credit.Name AS Кредит, CreditCurrency.Percentage AS Процент, Contract.Amount AS Сумма, Currency.Name AS Валюта, Contract.TermLength AS Срок, Contract.CreationDate AS [Дата получения], UserProfile.CompanyHead AS [Ф.И.О руководителя], UserProfile.CompanyPhone AS Телефон, UserProfile.CompanyEmail AS Email, Contract.ContractId AS [Номер договора] FROM Contract INNER JOIN Credit ON Contract.CreditId = Credit.CreditID INNER JOIN Currency ON Contract.CurrencyId = Currency.CurrencyID INNER JOIN Company ON Contract.CompanyId = Company.CompanyId INNER JOIN UserProfile ON Company.CompanyId = UserProfile.CompanyId INNER JOIN CreditCurrency ON Credit.CreditID = CreditCurrency.CreditId AND Currency.CurrencyID = CreditCurrency.CurrencyId WHERE (Contract.ContractId = @ContractId)">
    <SelectParameters>
        <asp:SessionParameter Name="ContractId" SessionField="contractId" 
            Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>
<br />
<b><asp:Label ID="PaymentsLabel" runat="server" Text="Оплаты:"></asp:Label></b><br/><br/>

<asp:GridView ID="GridViewPayments" Width="300px" runat="server" DataSourceID="SqlDataSourcePayments"
    AutoGenerateColumns="False">
    <Columns>
        <asp:BoundField DataField="Date" HeaderText="Дата оплаты" SortExpression="Date" />
        <asp:BoundField DataField="Amount" HeaderText="Сумма" SortExpression="Amount" />
        <asp:BoundField DataField="Name" HeaderText="Валюта" SortExpression="Name" />
    </Columns>
    <EmptyDataTemplate>
        Платежей пока нет.
    </EmptyDataTemplate>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourcePayments" runat="server" ConnectionString="<%$ ConnectionStrings:BankDBConnectionString %>"
    SelectCommand="SELECT ContractPayment.Date, (ContractPayment.MainAmount + ContractPayment.PercentageAmount) as Amount, Currency.Name FROM ContractPayment INNER JOIN Currency ON ContractPayment.CurrencyId = Currency.CurrencyID WHERE (ContractPayment.ConractId = @ContractId)">
    <SelectParameters>
        <asp:SessionParameter Name="ContractId" SessionField="contractId" 
            Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>
<br/>
<table>
<tr>
<td>
<b><asp:Label ID="Label" runat="server" Text="Основной долг: "></asp:Label></b>
</td>
<td>
<asp:Label ID="AllAmount" runat="server" Text="0"></asp:Label>
</td>
</tr>
<tr>
<td>
<b><asp:Label ID="Label2" runat="server" Text="Оплачено по основному долгу: "></asp:Label></b>
</td>
<td>
<asp:Label ID="PayedAmount" runat="server" Text="0"></asp:Label>
</td>
</tr>
<tr>
<td>
<b><asp:Label ID="Label3" runat="server" Text="Остаток: "></asp:Label></b>
</td>
<td>
<asp:Label ID="DebtAmount" runat="server" Text="0"></asp:Label>
</td>
</tr>
<tr>
<td>
<b><asp:Label ID="Label1" runat="server" Text="Выплачено по процентам: "></asp:Label></b>
</td>
<td>
<asp:Label ID="PercentageAmount" runat="server" Text="0"></asp:Label>
</td>
</tr>
</table>